package com.webank.webase.chain.mgr.repository.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import com.webank.webase.chain.mgr.repository.bean.TbChain;
import com.webank.webase.chain.mgr.repository.bean.TbChainExample;
import java.util.Optional;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;

public interface TbChainMapper {

    @Select({ "select count(1) from tb_chain" })
    public int countAll();

    @Select({ "select count(1) from tb_chain where chain_id = #{chainId}" })
    public int countByChainId(@Param("chainId") int chainId);

    @Select({ "select count(1) from tb_chain where chain_name = #{chainName}" })
    public int countByName(@Param("chainName") String chainName);

    @Select({ "select ", TbChainSqlProvider.ALL_COLUMN_FIELDS, " from tb_chain order by chain_name" })
    public List<TbChain> selectAll();

    @Select({ "select ", TbChainSqlProvider.ALL_COLUMN_FIELDS, " from tb_chain ", "where chain_name = #{chainName,jdbcType=VARCHAR}" })
    TbChain getByChainName(@Param("chainName") String chainName);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbChainSqlProvider.class, method = "countByExample")
    long countByExample(TbChainExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain
     *
     * @mbg.generated
     */
    @DeleteProvider(type = TbChainSqlProvider.class, method = "deleteByExample")
    int deleteByExample(TbChainExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain
     *
     * @mbg.generated
     */
    @Delete({ "delete from tb_chain", "where chain_id = #{chainId,jdbcType=INTEGER}" })
    int deleteByPrimaryKey(Integer chainId);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain
     *
     * @mbg.generated
     */
    @Insert({ "insert into tb_chain (chain_id, chain_name, ", "chain_type, description, ", "create_time, modify_time, ", "version, consensus_type, ", "storage_type, chain_status, ", "webase_sign_addr, deploy_type, ", "remark)", "values (#{chainId,jdbcType=INTEGER}, #{chainName,jdbcType=VARCHAR}, ", "#{chainType,jdbcType=TINYINT}, #{description,jdbcType=VARCHAR}, ", "#{createTime,jdbcType=TIMESTAMP}, #{modifyTime,jdbcType=TIMESTAMP}, ", "#{version,jdbcType=VARCHAR}, #{consensusType,jdbcType=VARCHAR}, ", "#{storageType,jdbcType=VARCHAR}, #{chainStatus,jdbcType=TINYINT}, ", "#{webaseSignAddr,jdbcType=VARCHAR}, #{deployType,jdbcType=TINYINT}, ", "#{remark,jdbcType=LONGVARCHAR})" })
    int insert(TbChain record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain
     *
     * @mbg.generated
     */
    @InsertProvider(type = TbChainSqlProvider.class, method = "insertSelective")
    int insertSelective(TbChain record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbChainSqlProvider.class, method = "selectByExampleWithBLOBs")
    @Results({ @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "chain_name", property = "chainName", jdbcType = JdbcType.VARCHAR), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "description", property = "description", jdbcType = JdbcType.VARCHAR), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "version", property = "version", jdbcType = JdbcType.VARCHAR), @Result(column = "consensus_type", property = "consensusType", jdbcType = JdbcType.VARCHAR), @Result(column = "storage_type", property = "storageType", jdbcType = JdbcType.VARCHAR), @Result(column = "chain_status", property = "chainStatus", jdbcType = JdbcType.TINYINT), @Result(column = "webase_sign_addr", property = "webaseSignAddr", jdbcType = JdbcType.VARCHAR), @Result(column = "deploy_type", property = "deployType", jdbcType = JdbcType.TINYINT), @Result(column = "remark", property = "remark", jdbcType = JdbcType.LONGVARCHAR) })
    List<TbChain> selectByExampleWithBLOBs(TbChainExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbChainSqlProvider.class, method = "selectByExample")
    @Results({ @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "chain_name", property = "chainName", jdbcType = JdbcType.VARCHAR), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "description", property = "description", jdbcType = JdbcType.VARCHAR), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "version", property = "version", jdbcType = JdbcType.VARCHAR), @Result(column = "consensus_type", property = "consensusType", jdbcType = JdbcType.VARCHAR), @Result(column = "storage_type", property = "storageType", jdbcType = JdbcType.VARCHAR), @Result(column = "chain_status", property = "chainStatus", jdbcType = JdbcType.TINYINT), @Result(column = "webase_sign_addr", property = "webaseSignAddr", jdbcType = JdbcType.VARCHAR), @Result(column = "deploy_type", property = "deployType", jdbcType = JdbcType.TINYINT) })
    List<TbChain> selectByExample(TbChainExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain
     *
     * @mbg.generated
     */
    @Select({ "select", "chain_id, chain_name, chain_type, description, create_time, modify_time, version, ", "consensus_type, storage_type, chain_status, webase_sign_addr, deploy_type, remark", "from tb_chain", "where chain_id = #{chainId,jdbcType=INTEGER}" })
    @Results({ @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "chain_name", property = "chainName", jdbcType = JdbcType.VARCHAR), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "description", property = "description", jdbcType = JdbcType.VARCHAR), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "version", property = "version", jdbcType = JdbcType.VARCHAR), @Result(column = "consensus_type", property = "consensusType", jdbcType = JdbcType.VARCHAR), @Result(column = "storage_type", property = "storageType", jdbcType = JdbcType.VARCHAR), @Result(column = "chain_status", property = "chainStatus", jdbcType = JdbcType.TINYINT), @Result(column = "webase_sign_addr", property = "webaseSignAddr", jdbcType = JdbcType.VARCHAR), @Result(column = "deploy_type", property = "deployType", jdbcType = JdbcType.TINYINT), @Result(column = "remark", property = "remark", jdbcType = JdbcType.LONGVARCHAR) })
    TbChain selectByPrimaryKey(Integer chainId);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbChainSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") TbChain record, @Param("example") TbChainExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbChainSqlProvider.class, method = "updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") TbChain record, @Param("example") TbChainExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbChainSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") TbChain record, @Param("example") TbChainExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbChainSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(TbChain record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain
     *
     * @mbg.generated
     */
    @Update({ "update tb_chain", "set chain_name = #{chainName,jdbcType=VARCHAR},", "chain_type = #{chainType,jdbcType=TINYINT},", "description = #{description,jdbcType=VARCHAR},", "create_time = #{createTime,jdbcType=TIMESTAMP},", "modify_time = #{modifyTime,jdbcType=TIMESTAMP},", "version = #{version,jdbcType=VARCHAR},", "consensus_type = #{consensusType,jdbcType=VARCHAR},", "storage_type = #{storageType,jdbcType=VARCHAR},", "chain_status = #{chainStatus,jdbcType=TINYINT},", "webase_sign_addr = #{webaseSignAddr,jdbcType=VARCHAR},", "deploy_type = #{deployType,jdbcType=TINYINT},", "remark = #{remark,jdbcType=LONGVARCHAR}", "where chain_id = #{chainId,jdbcType=INTEGER}" })
    int updateByPrimaryKeyWithBLOBs(TbChain record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain
     *
     * @mbg.generated
     */
    @Update({ "update tb_chain", "set chain_name = #{chainName,jdbcType=VARCHAR},", "chain_type = #{chainType,jdbcType=TINYINT},", "description = #{description,jdbcType=VARCHAR},", "create_time = #{createTime,jdbcType=TIMESTAMP},", "modify_time = #{modifyTime,jdbcType=TIMESTAMP},", "version = #{version,jdbcType=VARCHAR},", "consensus_type = #{consensusType,jdbcType=VARCHAR},", "storage_type = #{storageType,jdbcType=VARCHAR},", "chain_status = #{chainStatus,jdbcType=TINYINT},", "webase_sign_addr = #{webaseSignAddr,jdbcType=VARCHAR},", "deploy_type = #{deployType,jdbcType=TINYINT}", "where chain_id = #{chainId,jdbcType=INTEGER}" })
    int updateByPrimaryKey(TbChain record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain
     *
     * @mbg.generated
     */
    @Options(useGeneratedKeys = true, keyProperty = "chainId", keyColumn = "chain_id")
    @Insert({ "<script>", "insert into tb_chain (chain_id, ", "chain_name, chain_type, ", "description, create_time, ", "modify_time, version, ", "consensus_type, storage_type, ", "chain_status, webase_sign_addr, ", "deploy_type, remark)", "values<foreach collection=\"list\" item=\"detail\" index=\"index\" separator=\",\">(#{detail.chainId,jdbcType=INTEGER}, ", "#{detail.chainName,jdbcType=VARCHAR}, #{detail.chainType,jdbcType=TINYINT}, ", "#{detail.description,jdbcType=VARCHAR}, #{detail.createTime,jdbcType=TIMESTAMP}, ", "#{detail.modifyTime,jdbcType=TIMESTAMP}, #{detail.version,jdbcType=VARCHAR}, ", "#{detail.consensusType,jdbcType=VARCHAR}, #{detail.storageType,jdbcType=VARCHAR}, ", "#{detail.chainStatus,jdbcType=TINYINT}, #{detail.webaseSignAddr,jdbcType=VARCHAR}, ", "#{detail.deployType,jdbcType=TINYINT}, #{detail.remark,jdbcType=LONGVARCHAR})</foreach></script>" })
    int batchInsert(List<TbChain> list);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbChainSqlProvider.class, method = "getOneByExample")
    @Results({ @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "chain_name", property = "chainName", jdbcType = JdbcType.VARCHAR), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "description", property = "description", jdbcType = JdbcType.VARCHAR), @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP), @Result(column = "version", property = "version", jdbcType = JdbcType.VARCHAR), @Result(column = "consensus_type", property = "consensusType", jdbcType = JdbcType.VARCHAR), @Result(column = "storage_type", property = "storageType", jdbcType = JdbcType.VARCHAR), @Result(column = "chain_status", property = "chainStatus", jdbcType = JdbcType.TINYINT), @Result(column = "webase_sign_addr", property = "webaseSignAddr", jdbcType = JdbcType.VARCHAR), @Result(column = "deploy_type", property = "deployType", jdbcType = JdbcType.TINYINT), @Result(column = "remark", property = "remark", jdbcType = JdbcType.LONGVARCHAR) })
    Optional<TbChain> getOneByExample(TbChainExample example);
}
